/**
***********************************************************************
*
* Copyright 2011 Stefan Wöhle
*
* This file is part of PixelMath
*
* PixelMath is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PixelMath is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PixelMath. If not, see <http://www.gnu.org/licenses/>.
*
***********************************************************************
*/

#ifndef FORMULAEXCEPTION_H
#define FORMULAEXCEPTION_H

#include <QObject>

enum FormulaErrorCode {
    GENERAL_ERROR,          // unspecified error, see msg of exception for further descriptions
    PARAMS_OUT_OF_RANGE,    // a parameter is out of range, for example the x- or y-value in a
                            // localizedfunction is bigger then the Formula::sourceImage
    INVALID_SOURCE_IMAGE,   // the Formula::sourceImage is not set, please load a image and try again
    DIVISION_BY_ZERO,       // the right operand of a division is zero
    MISSING_PARAMETER       // a subformula in a formula was not specified
};

/*********************************************************
 *
 *  FormulaException
 *
 *  This is a wrapper for exceptions in PixelMath. It
 *  contains a message and a code to throw and handle
 *  exceptions on a higher level in the application. The
 *  normal behavior is to inform the user about the error
 *  via a QMessageBox.
 *
 **********************************************************/

class FormulaException : public QObject
{
    Q_OBJECT
private:
    QString msg;
    FormulaErrorCode code;

public:
    explicit FormulaException(QString msg, FormulaErrorCode code, QObject *parent = 0);
    FormulaException(const FormulaException& e);
    QString getMsg();
    FormulaErrorCode getCode();
};

#endif // FORMULAEXCEPTION_H
